<script type="text/javascript">
	$(document).ready(function() {
	setTimeout(function(){
	  $("#kotak").fadeOut("slow", function () {
		$("#kotak").remove();
	  });    
	}, 3000);
	});
	
	function brand_change(){
		var brand_id = $("#prod_brand_id").val();
		var kat_level = $("#kat_level").val();
		var parent_kat_id = $("#parent_kat_id");
		var parent_selected = <?php echo $row->parent_kat_id?>;
		//parent_kat_id.html('<option>Loading..&nbsp;&nbsp;</option>');
		if(kat_level!=1){
			var post_data = 'brand_id='+brand_id+
							'&kat_level='+kat_level+
							'&selected='+parent_selected;
			$.ajax({
				type: "POST",
				url: "<?php echo base_url().'backend/kat_produk/select_category/' ?>",
				data: post_data,
				success: function(return_data) {
					parent_kat_id.html(return_data);
				}
			});
		}
		else{
			parent_kat_id.html('<option value="0">No Parent</option>');
		}
	}
	
	function get_parent_select(){
		var brand_id = $("#prod_brand_id").val();
		var kat_level = $("#kat_level").val();
		var parent_kat_id = $("#parent_kat_id");
		var parent_selected = <?php echo $row->parent_kat_id?>;
		//parent_kat_id.html('<option>Loading..&nbsp;&nbsp;</option>');
		if(kat_level!=1){
			var post_data = 'brand_id='+brand_id+
							'&kat_level='+kat_level+
							'&selected='+parent_selected;
			$.ajax({
				type: "POST",
				url: "<?php echo base_url().'backend/kat_produk/select_category/' ?>",
				data: post_data,
				success: function(return_data) {
					parent_kat_id.html(return_data);
				}
			});
		}
		else{
			parent_kat_id.html('<option value="0">No Parent</option>');
		}
	}  
</script>
</style>
<div class="left"></div>
<div class="right"></div>
<div class="heading">
	<h1 style="background-image: url('<?php echo base_url()?>assets/images/product.png');">Katalog</h1>
</div>
<div class="yui-gc wrapper">
    <h1>Kategori Produk <?php echo $row->nama_kategori;?></h1>
	<?php echo $this->session->flashdata('message_type');?>
	<form action="" method="post" enctype="multipart/form-data">
    <div class="yui-u first">
        <fieldset>
		<legend>Edit Kategori Produk</legend>
		<ul>
			<li>
				<label for="name">Nama</label>
				<?php echo form_error('nama_kategori', '<div class="error">', '</div>'); ?>
				<input type="text" name="nama_kategori" class="title" value="<?php echo $row->nama_kategori;?>">
			</li>
			<li>
				<label for="description">Deskripsi</label>
				<?php echo form_error('deskripsi', '<div class="error">', '</div>'); ?>
				<textarea id="description" name="deskripsi" class="text h80"><?php echo $row->deskripsi;?></textarea>
			
			</ul>
		</fieldset>
	</div>
	<div class="yui-u">
		<fieldset>
		<legend>Detail Kategori</legend>
		<ul>
			<li>
				<label for="prod_brand_id">Vendor / Manufaktur</label>
				<?php echo form_error('prod_brand_id', '<div class="error">', '</div>'); ?>
				<?php echo vendorDropdown($row->brand_id,TRUE);?>
			</li>
			<li>
				<label for="brand_id">Level</label>
				<?php
				$attr = 'id="kat_level" style="width:200px;" onchange="get_parent_select();"';
				$options = array(
				  '1' => 'Level 1 - Parent Category',
				  '2'=> 'Level 2',
				  '3' => 'Level 3'
				);
				echo form_dropdown('kat_level', $options, $row->kat_level, $attr);
				?>
			</li>
			<li id="parent_kat">
				<label for="parent_kat_id">Parent Category</label>
				<select name="parent_kat_id" id="parent_kat_id" style="width:300px;">
				<?php
					$kat_level = $row->kat_level;
					echo select_parent_category($kat_level,$row->brand_id, $row->parent_kat_id);
				?>
				</select>
			</li>
			<li>
				<label for="caps_posisi">Caps Position</label>
				<?php
				$attr = 'id="caps_posisi" style="width:200px;"';
				$options = array(
				  'left' => 'Left',
				  'right'=> 'Right'
				);
				echo form_dropdown('caps_posisi', $options, $row->caps_posisi, $attr);
				?>
			</li>
			<li>
				<label for="urut">Ordering</label>
				<input type="text" name='urut' class="text" value="<?php echo $row->urut?>" style="width:40px;">
			</li>
			<li>
				<input type="submit" value="Simpan" class=""> atau <?php echo anchor('backend/kat_produk','Batal')?>
			</li>
		</ul>
		</fieldset>
	</div>
</form>
</div>